<template>
  <div class="are_buil_romm">
    <!-- 新增房间 -->
    <el-dialog
      width="720px"
      custom-class="customWidth"
      center
      :before-close="roomcloseDialog"
      title="新增房间"
      :close-on-click-modal="false"
      :visible.sync="addroomDialogFormVisible"
    >
      <el-form
        :model="addroomataForm"
        :rules="addroomataRule"
        ref="addroomataForm"
        label-width="100px"
        id="addroom_css"
      >
        <el-form-item label="楼栋" prop="areabuldingname">
          <el-col :span="15">
            <el-input v-model="addroomataForm.areabuldingname" size="mini" disabled></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="楼层" prop="layers">
          <el-col :span="15">
            <el-input v-model="addroomataForm.layers" size="mini" disabled></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="名称" prop="roomname">
          <el-col :span="15">
            <el-input v-model="addroomataForm.roomname" size="mini"></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="类型">
          <el-col :span="24">
            <el-radio-group v-model="roomradio" @change="checketerminalselect">
              <el-radio :label="0">房间</el-radio>
              <el-radio :label="1">食堂窗口</el-radio>
              <el-radio :label="3">小卖部</el-radio>
              <el-radio :label="2">通道门</el-radio>
              <el-radio :label="4">公共场所</el-radio>
            </el-radio-group>
          </el-col>
        </el-form-item>
        <el-form-item label="编号" v-if="roomradio != 2">
          <el-col :span="5" prop="roomCode">
            <el-input v-model="addroomataForm.roomCode" size="mini" maxlength="2"></el-input>
          </el-col>
          <el-col :span="3">
            <div class="xuhaoxain">-</div>
          </el-col>
          <el-col :span="5" prop="roomCodeEnd">
            <el-input v-model="addroomataForm.roomCodeEnd" size="mini" maxlength="2"></el-input>
          </el-col>
          <el-col :span="10" :style="{ paddingLeft: '20px' }">
            <!-- <el-checkbox v-model="addroomataForm.repeatnumber"></el-checkbox> -->
            <span>自动忽略重复号码</span>
          </el-col>
        </el-form-item>
        <!-- 老门禁编号 -->
        <el-form-item label="编号" v-if="roomradio == 2 && !isNewAcce(addroomataForm.accesscontrol)">
          <el-col :span="5" prop="roomCode">
            <el-input v-model="addroomataForm.roomCode" size="mini" maxlength="2"></el-input>
          </el-col>
          <el-col :span="3">
            <div class="xuhaoxain">-</div>
          </el-col>
          <el-col :span="5" prop="roomCodeEnd">
            <el-input v-model="addroomataForm.roomCodeEnd" size="mini" maxlength="2"></el-input>
          </el-col>
          <el-col :span="10" :style="{ paddingLeft: '20px' }">
            <!-- <el-checkbox v-model="addroomataForm.repeatnumber"></el-checkbox> -->
            <span>自动忽略重复号码</span>
          </el-col>
        </el-form-item>
        <!-- 新门禁编号 -->
        <el-form-item label="编号" v-if="roomradio == 2 && isNewAcce(addroomataForm.accesscontrol)">
          <el-col :span="10" prop="roomCodeEnd">
            <el-input v-model="addroomataForm.roomCodeEnd" size="mini" maxlength="2"></el-input>
          </el-col>
          <el-col :span="10" :style="{ paddingLeft: '20px' }">
            <!-- <el-checkbox v-model="addroomataForm.repeatnumber"></el-checkbox> -->
            <!-- <span>自动忽略重复号码</span> -->
          </el-col>
        </el-form-item>
        <!-- 网关 -->
        <el-form-item label="网关" prop="wanguang" v-if="roomradio == 2 ? false : true">
          <el-col :span="15">
            <el-select
              clearable
              v-model="addroomataForm.wanguang"
              placeholder="请选择网关"
              size="mini"
              style="width: 100%"
              value-key="value"
              @change="wanguangChange"
            >
              <el-option
                v-for="item in addroomataForm.wanguangoption"
                :key="item.value"
                :label="item.label"
                :value="item"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>
        <el-form-item label="人数上限" prop="limitNum" v-show="roomradio == 0 ? true : false">
          <el-col :span="15">
            <el-input-number
              size="mini"
              v-model="addroomataForm.limitNum"
              :min="1"
              :max="9999"
              label="描述文字"
            ></el-input-number>
          </el-col>
        </el-form-item>
        <!-- 门锁 -->
        <el-form-item label="门锁" prop="doorlock" v-show="roomradio == 0 ? true : false">
          <el-col :span="5">
            <el-select
              clearable
              v-model="addroomataForm.doorlock"
              placeholder="设备型号"
              size="mini"
              style="width: 100%"
              @change="handleDoor"
            >
              <el-option
                v-for="item in doorlockoption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-col>
          <el-col :span="5">
            <el-select
              v-model="addroomataForm.nameListType"
              placeholder="名单格式 "
              size="mini"
              style="width: 100px"
            >
              <el-option
                v-for="item in nameListOption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-col>
          <el-col :span="6">
            <label>数量</label>
            <el-input-number
              v-model="addroomataForm.doorNumber"
              :min="1"
              size="mini"
              style="width:100px"
            ></el-input-number>
          </el-col>
          <el-col :span="8">
            <label>所属网关</label>
            <el-select
              clearable
              v-model="addroomataForm.doorwanguang"
              placeholder="所属网关"
              size="mini"
              value-key="value"
              @change="(res) => roomWangChange(res, 22)"
              style="width:130px"
            >
              <el-option
                v-for="item in addroomataForm.wanguangoption"
                :key="item.value"
                :label="item.label"
                :value="item"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>

        <!-- 水控 -->
        <el-form-item label="水控" prop="watercontroller" v-show="roomradio == 0 ? true : false">
          <el-col :span="9">
            <el-select
              clearable
              v-model="addroomataForm.watercontroller"
              placeholder="选择设备型号"
              size="mini"
              style="width: 100%"
            >
              <el-option
                v-for="item in wateroption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-col>
          <el-col :span="6" :offset="1">
            <label>数量</label>
            <el-input-number
              v-model="addroomataForm.waterNumber"
              :min="1"
              size="mini"
              style="width:100px"
            ></el-input-number>
          </el-col>
          <el-col :span="8">
            <label>所属网关</label>
            <el-select
              clearable
              v-model="addroomataForm.waterwanguang"
              placeholder="所属网关"
              size="mini"
              value-key="value"
              @change="(res) => roomWangChange(res, 6)"
              style="width:130px"
            >
              <el-option
                v-for="item in addroomataForm.wanguangoption"
                :key="item.value"
                :label="item.label"
                :value="item"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>

        <!-- 电控 -->
        <el-form-item label="电控" prop="electricity" v-show="roomradio == 0 ? true : false">
          <el-col :span="9">
            <el-select
              clearable
              v-model="addroomataForm.electricity"
              placeholder="选择设备型号"
              size="mini"
              style="width: 100%"
            >
              <el-option
                v-for="item in electricityoption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-col>
          <el-col :span="6" :offset="1">
            <label>数量</label>
            <el-input-number
              v-model="addroomataForm.eleNumber"
              :min="1"
              size="mini"
              style="width:100px"
            ></el-input-number>
          </el-col>
          <el-col :span="8">
            <label>所属网关</label>
            <el-select
              clearable
              v-model="addroomataForm.elewanguang"
              placeholder="所属网关"
              size="mini"
              value-key="value"
              @change="(res) => roomWangChange(res, 31)"
              style="width:130px"
            >
              <el-option
                v-for="item in addroomataForm.wanguangoption"
                :key="item.value"
                :label="item.label"
                :value="item"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>
        <!-- 
        homewanguang: '',-->
        <!-- 空调 -->
        <el-form-item label="空调" prop="airconditioning" v-show="roomradio == 0 ? true : false">
          <el-col :span="9">
            <el-select
              clearable
              v-model="addroomataForm.airconditioning"
              placeholder="选择设备型号"
              size="mini"
              style="width: 100%"
            >
              <el-option
                v-for="item in airconditioningoption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-col>
          <el-col :span="6" :offset="1">
            <label>数量</label>
            <el-input-number
              v-model="addroomataForm.airNumber"
              :min="1"
              size="mini"
              style="width:100px"
            ></el-input-number>
          </el-col>
          <el-col :span="8">
            <label>所属网关</label>
            <el-select
              clearable
              v-model="addroomataForm.airwanguang"
              placeholder="所属网关"
              size="mini"
              value-key="value"
              @change="(res) => roomWangChange(res, 24)"
              style="width:130px"
            >
              <el-option
                v-for="item in addroomataForm.wanguangoption"
                :key="item.value"
                :label="item.label"
                :value="item"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>
        <!-- 归宿终端 -->
        <el-form-item label="归宿终端" prop="hometerminal" v-show="roomradio == 0 ? true : false">
          <el-col :span="9">
            <el-select
              clearable
              v-model="addroomataForm.hometerminal"
              placeholder="选择设备型号"
              size="mini"
              style="width: 100%"
            >
              <el-option
                v-for="item in hometerminaloption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-col>
          <el-col :span="6" :offset="1">
            <label>数量</label>
            <el-input-number
              v-model="addroomataForm.homeNumber"
              :min="1"
              size="mini"
              style="width:100px"
            ></el-input-number>
          </el-col>
          <el-col :span="8">
            <label>所属网关</label>
            <el-select
              clearable
              v-model="addroomataForm.airwanguang"
              placeholder="所属网关"
              size="mini"
              value-key="value"
              @change="(res) => roomWangChange(res, 24)"
              style="width:130px"
            >
              <el-option
                v-for="item in addroomataForm.wanguangoption"
                :key="item.value"
                :label="item.label"
                :value="item"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>
        <!-- 消费类型 -->
        <el-form-item
          label="消费机"
          prop="consumptiontype"
          v-show="roomradio == 1 || roomradio == 3 ? true : false"
        >
          <el-col :span="15">
            <el-select
              clearable
              v-model="addroomataForm.consumptiontype"
              placeholder="选择设备型号"
              size="mini"
              style="width: 100%"
            >
              <el-option
                v-for="item in consumption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>
        <!-- 充值机 -->
        <el-form-item label="充值机" prop="rechargetype" v-show="roomradio == 1 ? true : false">
          <el-col :span="15">
            <el-select
              clearable
              v-model="addroomataForm.rechargetype"
              placeholder="选择设备型号"
              size="mini"
              style="width: 100%"
            >
              <el-option
                v-for="item in recharge"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>
          <!-- 圈存机 -->
        <el-form-item label="圈存机" prop="circlingtype" v-show="roomradio == 1 ? true : false">
          <el-col :span="15">
            <el-select
              clearable
              v-model="addroomataForm.circlingtype"
              placeholder="选择设备型号"
              size="mini"
              style="width: 100%"
            >
              <el-option
                v-for="item in circling"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>
        <!-- 门禁 -->
        <el-form-item
          :label="isNewAcce(addroomataForm.accesscontrol)?'门禁型号':'门禁型号'"
          prop="accesscontrol"
          v-show="roomradio == 2 ? true : false"
        >
          <el-col :span="15">
            <el-select
              clearable
              v-model="addroomataForm.accesscontrol"
              placeholder="选择设备型号"
              size="mini"
              style="width: 100%"
              @change="getAceeWangguan"
            >
              <el-option
                v-for="item in accesscontroloption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>
        <!-- 控制器名称 -->
        <el-form-item
          label="控制器名称"
          prop="acceWanguang"
          v-show="roomradio == 2  && isNewAcce(addroomataForm.accesscontrol)"
        >
          <el-col :span="15">
            <el-select
              clearable
              v-model="addroomataForm.acceWanguang"
              placeholder="选择控制器"
              size="mini"
              style="width: 100%"
              value-key="value"
            >
              <el-option
                v-for="item in acceWanguangOption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>
        <!-- 进出方向 -->
        <el-form-item
          label="进出方向"
          prop="openType"
          v-show="roomradio == 2  && isNewAcce(addroomataForm.accesscontrol)"
        >
          <el-col :span="15">
            <el-select
              v-model="addroomataForm.openType"
              placeholder="请选择"
              size="mini"
              style="width: 100%"
            >
              <el-option
                v-for="item in openTypeOption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>
        <!-- 门编号 -->
        <el-form-item
          label="门编号"
          prop="doorCode"
          v-show="roomradio == 2 && isNewAcce(addroomataForm.accesscontrol)"
        >
          <el-col :span="15">
            <el-select
              clearable
              v-model="addroomataForm.doorCode"
              placeholder="请选择"
              size="mini"
              style="width: 100%"
            >
              <el-option v-for="item in 2" :key="item" :label="item" :value="item"></el-option>
            </el-select>
          </el-col>
        </el-form-item>
        <!-- 门禁ip -->
        <el-form-item
          label="人脸机ip"
          prop="doorFaceIp"
          v-show="roomradio == 2  && isNewAcce(addroomataForm.accesscontrol)"
        >
          <el-col :span="15">
            <el-input v-model="addroomataForm.doorFaceIp" size="mini"></el-input>
          </el-col>
        </el-form-item>
        <!-- 门禁ip -->
        <el-form-item
          label="ip"
          prop="ip"
          v-show="roomradio == 2 && !isNewAcce(addroomataForm.accesscontrol)"
        >
          <el-col :span="15">
            <el-input v-model="addroomataForm.ip" size="mini"></el-input>
          </el-col>
        </el-form-item>
        <!-- 门禁端口 -->
        <el-form-item
          label="端口"
          prop="port"
          v-show="roomradio == 2  && !isNewAcce(addroomataForm.accesscontrol)"
        >
          <el-col :span="15">
            <el-input v-model="addroomataForm.port" size="mini"></el-input>
          </el-col>
        </el-form-item>
        <!-- 无人售货机 -->
        <el-form-item label="无人售货机" prop="unsold" v-show="roomradio == 4 ? true : false">
          <el-col :span="15">
            <el-select
              clearable
              v-model="addroomataForm.unsold"
              placeholder="请选择"
              size="mini"
              style="width: 100%"
            >
              <el-option
                v-for="item in unsoldoption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>
        <!-- 直饮水 -->
        <el-form-item label="直饮水" prop="drinkingwater" v-show="roomradio == 4 ? true : false">
          <el-col :span="15">
            <el-select
              clearable
              v-model="addroomataForm.drinkingwater"
              placeholder="请选择"
              size="mini"
              style="width: 100%"
            >
              <el-option
                v-for="item in drinkingwateroption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>
        <!-- 电吹风 -->
        <el-form-item label="电吹风" prop="hairdryer" v-show="roomradio == 4 ? true : false">
          <el-col :span="15">
            <el-select
              clearable
              v-model="addroomataForm.hairdryer"
              placeholder="请选择"
              size="mini"
              style="width: 100%"
            >
              <el-option
                v-for="item in hairdryeroption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>
        <!-- 公话 -->
        <el-form-item label="公话" prop="voip" v-show="roomradio == 4 ? true : false">
          <el-col :span="15">
            <el-select
              clearable
              v-model="addroomataForm.voip"
              placeholder="请选择"
              size="mini"
              style="width: 100%"
            >
              <el-option
                v-for="item in voipoption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>
        <!-- 发卡机 -->
        <el-form-item label="发卡机" prop="sendcards" v-show="roomradio == 4 ? true : false">
          <el-col :span="15">
            <el-select
              clearable
              v-model="addroomataForm.sendcards"
              placeholder="请选择"
              size="mini"
              style="width: 100%"
            >
              <el-option
                v-for="item in sendcardsoption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="addroomvisible()">取消</el-button>
        <el-button type="primary" @click="addroomataFormSubmit()">确定</el-button>
      </span>
    </el-dialog>
    <!-- 绑定网关  -->
    <el-dialog
      width="600px"
      custom-class="customWidth"
      center
      title="绑定网关"
      :before-close="roomgatewacloseDialog"
      :close-on-click-modal="false"
      :visible.sync="bundlegatewayVisible"
    >
      <el-transfer
        style="text-align: left; display: inline-block"
        v-model="gatewayvalue"
        filterable
        :left-default-checked="[]"
        :right-default-checked="[]"
        :titles="['楼栋网关', '楼层网关']"
        :button-texts="['移除', '分配']"
        @change="handleChange"
        :data="controllerListdata"
      ></el-transfer>
      <span slot="footer" class="dialog-footer">
        <el-button @click="bundlegatewayroomvisible()">取消</el-button>
        <el-button type="primary" @click="bundlegatewayroomataFormSubmit()">确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    let checkroomnumber = (rule, value, callback) => {
      let roomnumberReg = /^99$|^(\d|[1-9]\d)$/
      if (value == '') {
        callback(new Error('序号不能为空！'))
      } else if (!roomnumberReg.test(value)) {
        callback(new Error('请填写正确的序号格式！'))
      } else {
        callback()
      }
    }

    let checklimt = (rule, value, callback) => {
      let limtnumReg = /(^[1-9]\d*$)/
      if (value == '') {
        callback(new Error('入住人数不能为空！'))
      } else if (!limtnumReg.test(value)) {
        callback(new Error('请填写正确的入住人数数据格式！'))
      } else {
        callback()
      }
    }
    return {
      pageSize: 8,
      pageNum: 1,
      //楼栋id
      buildingGuid: '',
      //区域id
      areaid: '',
      //设备类型
      terminalRequests: [],
      //网关信息
      gatewayvalue: [],
      controllerListdata: [],
      //楼层
      layers: 0,
      //新增房间选项
      roomradio: 999,
      //门锁类型
      doorlockoption: [],
      // 门锁名单格式类型
      nameListOption: [],
      //水控类型
      wateroption: [],
      //电控类型
      electricityoption: [],
      //空调类型
      airconditioningoption: [],
      //电吹风
      hairdryeroption: [],
      // 公话
      voipoption: [],
      // 发卡机
      sendcardsoption: [],
      //直饮水
      drinkingwateroption: [
        {
          value: 59,
          label: 'F662CW'
        },
        {
          value: 51,
          label: 'F600CW'
        },
        {
          value: 56,
          label: 'F562CW'
        },
        {
          value: 50,
          label: 'F500CW'
        }
      ],
      //无人售货
      unsoldoption: [],
      //归宿终端
      hometerminaloption: [],
      //消费类型
      consumption: [],
      // 充值机类型
      recharge: [],
      // 圈存机
      circling:[],
      // 通道
      accesscontroloption: [],
      //房间
      addroomataForm: {
        limitNum: 4,
        areabuldingname: '',
        areaGuid: '',
        layers: '',
        roomCode: '1',
        roomCodeEnd: 1,
        roomType: '',
        roomname: '',
        /**门锁、电控、水控、归宿终端设备个数 */
        doorNumber: 1,
        waterNumber: 1,
        eleNumber: 1,
        airNumber: 1,
        homeNumber: 1,
        /**门锁、电控、水控、归宿终端所属网关 */
        doorwanguang: '',
        waterwanguang: '',
        elewanguang: '',
        airwanguang: '',
        homewanguang: '',

        //无人售货
        unsold: '',
        //直饮水
        drinkingwater: '',
        // 电吹风
        hairdryer: '',
        // 公话
        voip: '',
        sendcards: '',
        //房间
        // 门锁
        doorlock: '',
        // 门锁名单格式
        nameListType: '',
        electricity: '',
        watercontroller: '',
        airconditioning: '',
        hometerminal: '',
        // 消费类型
        consumptiontype: '',
        // 充值机类型
        rechargetype: '',
        // 圈存机类型
         circlingtype: '',
        //通道
        accesscontrol: '',
        // 门编号
        doorCode: 1,
        // 门禁网关
        acceWanguang: '',
        // 进出方向
        openType: 0,
        //门禁人脸机IP
        doorFaceIp: '',
        watercontrollerisuse: true,
        doorlockcheckisuse: true,
        electricityisuse: true,
        airconditioningisuse: true,
        hometerminalisuse: true,
        //消费
        consumptiontypeisuse: true,
        //通道门
        accesscontrolisuse: true,
        //无人售货
        unsoldisuse: true,
        //直饮水
        drinkingwaterisuse: true,
        //电吹风
        hairdryerisuse: true,
        //网关
        wanguang: [],
        wanguangoption: [],
        wanguangoptionInit: [],
        wanguangoptionInit1: [],
        wanguangoptionInit2: [],
        // 端口
        ip: '',
        port: '4001'
      },
      //
      addroomDialogFormVisible: false,
      bundlegatewayVisible: false,
      addroomataRule: {
        //  roomCode:[
        //    { required: true, validator: checkroomnumber, trigger: 'blur' }
        //  ],
        //  roomCodeEnd:[
        //    { required: true, validator: checkroomnumber, trigger: 'blur' }
        //  ],
        //  limitNum:[
        //    { required: true, validator: checklimt, trigger: 'blur' }
        //  ]
      },
      /**门禁处理 {modelId: 70,modelName: "A1262T"}*/
      // 新的门禁类型
      newAccesscontrol: [70],
      // 门禁网关
      acceWanguangOption: [],
      // 进出方向
      openTypeOption: [
        { label: '进门', value: 0 },
        { label: '出门', value: 1 }
      ]
    }
  },
  computed: {
    changeschoolid: {
      get() {
        return this.$store.state.user.changeschoolid
      }
    }
  },

  props: ['unitGuid'],
  mounted() {},
  methods: {
    /**
     * 门禁处理
     */
    // 判断是否存在
    isNewAcce(newAcce) {
      return this.newAccesscontrol.includes(newAcce)
    },
    // 获取门禁网关
    getAceeWangguan(val) {
      this.addroomataForm.acceWanguang = ''
      this.$http({
        url: this.$http.adornUrl('/api/v1/device/controller-entrance-pithy'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            buildingGuid: this.buildingGuid,
            layer: this.layers,
            controllerModel: val
          },
          messageType: 0
        })
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          let Arr = data.messageContent
          this.acceWanguangOption = []
          for (var i = 0; i < Arr.length; i++) {
            var itemObj = {
              label: Arr[i].controllerName,
              value: Arr[i].controllerGuid,
              type: 21
            }
            this.acceWanguangOption.push(itemObj)
          }
        } else {
          this.$message.error(data.errorMessage)
        }
      })
    },

    /**
     * 门锁处理
     */
    // 门锁型号选择用来配置门锁设备使用名单格式
    handleDoor(val) {
      console.log(val)
      this.addroomataForm.nameListType = ''
      if (val == 45) {
        this.nameListOption = [
          { value: 1, label: '16字节' },
          { value: 2, label: '32字节' }
        ]
        this.addroomataForm.nameListType = 1
      } else if (val == 46 || val == 49) {
        // EL180	49
        this.nameListOption = [{ value: 1, label: '16字节' }]
        this.addroomataForm.nameListType = 1
      } else if (val == 47 || val == 48 || val == 43) {
        this.nameListOption = [{ value: 2, label: '32字节' }]
        this.addroomataForm.nameListType = 2
      }
    },
    /**
     * 网关处理
     */
    // 房间类型的网关处理
    roomWangChange(val, type) {
      if (type == 22) {
        this.addroomataForm.doorlock = ''
      }
      if (type == 6) {
        this.addroomataForm.watercontroller = ''
      }
      if (type == 31) {
        this.addroomataForm.electricity = ''
      }
      // MC3611	91	MC3612	92 CT1601	93 CT1612	95	MC3622	96	MC3632	98
      if (val.controllerModel == 91 || val.controllerModel == 92) {
        if (type == 22) {
          // 门锁
          this.doorlockoption = [
            { value: 43, label: 'EL200CW' },
            { value: 45, label: 'EL150CW' },
            { value: 48, label: 'EL300CW' },
            { value: 49, label: 'EL180CW' }
          ]
        }
        if (type == 6) {
          // 水控
          this.wateroption = [
            { value: 32, label: 'F300CW' },
            { value: 50, label: 'F500CW' },
            { value: 51, label: 'F600CW' }
          ]
        }

        if (type == 31) {
          this.electricityoption = []
        }
      } else if (val.controllerModel == 96) {
        if (type == 22) {
          // 门锁
          this.doorlockoption = [
            { value: 43, label: 'EL200CW' },
            { value: 45, label: 'EL150CW' },
            { value: 48, label: 'EL300CW' },
            { value: 49, label: 'EL180CW' }
          ]
        }
        if (type == 6) {
          // 水控
          this.wateroption = [
            { value: 56, label: 'F562CW' },
            { value: 59, label: 'F662CW' }
          ]
        }
        if (type == 31) {
          // 电控
          this.electricityoption = []
        }
      } else if (val.controllerModel == 93 || val.controllerModel == 95) {
        if (type == 22) {
          // 门锁
          this.doorlockoption = [
            { value: 46, label: 'EL150C-A' },
            { value: 47, label: 'EL150C-B' }
          ]
        }
        if (type == 6) {
          this.wateroption = []
        }
        if (type == 31) {
          this.electricityoption = []
        }
      } else if (val.controllerModel == 97) {
        if (type == 22) {
          this.doorlockoption = []
        }
        if (type == 6) {
          this.wateroption = []
        }
        if (type == 31) {
          // 电控
          this.electricityoption = [{ value: 71, label: 'EC100' }]
        }
      } else if (val.controllerModel == 98) {
        if (type == 22) {
          // 门锁
          this.doorlockoption = [
            { value: 43, label: 'EL200CW' },
            { value: 45, label: 'EL150CW' },
            { value: 46, label: 'EL150C-A' },
            { value: 47, label: 'EL150C-B' },
            { value: 48, label: 'EL300CW' },
            { value: 49, label: 'EL180CW' }
          ]
        }
        if (type == 6) {
          // 水控
          this.wateroption = [
            { value: 56, label: 'F562CW' },
            { value: 59, label: 'F662CW' }
          ]
        }
        if (type == 31) {
          // 电控
          this.electricityoption = []
        }
      } else {
        if (type == 22) {
          // 门锁
          this.doorlockoption = [
            { value: 43, label: 'EL200CW' },
            { value: 45, label: 'EL150CW' },
            { value: 46, label: 'EL150C-A' },
            { value: 47, label: 'EL150C-B' },
            { value: 48, label: 'EL300CW' },
            { value: 49, label: 'EL180CW' }
          ]
        }
        if (type == 6) {
          // 水控
          this.wateroption = [
            { value: 32, label: 'F300CW' },
            { value: 50, label: 'F500CW' },
            { value: 51, label: 'F600CW' },
            { value: 56, label: 'F562CW' },
            { value: 59, label: 'F662CW' }
          ]
        }
        if (type == 31) {
          // 电控
          this.electricityoption = [{ value: 71, label: 'EC100' }]
        }
      }
      // 空调
      this.airconditioningoption = [{ value: 125, label: 'KongTiao' }]
      // 归宿终端
      this.hometerminaloption = [{ value: 130, label: 'GuiSuZhongDuan' }]
    },
    // 全部的网关选择
    wanguangChange(val) {
      // 房间
      if (this.roomradio == 0) {
        this.addroomataForm.doorlock = ''
        this.addroomataForm.electricity = ''
        this.addroomataForm.watercontroller = ''
        this.addroomataForm.airconditioning = ''
        this.addroomataForm.hometerminal = ''
        this.$set(
          this.addroomataForm,
          'doorwanguang',
          this.addroomataForm.wanguang
        )
        this.$set(
          this.addroomataForm,
          'waterwanguang',
          this.addroomataForm.wanguang
        )
        this.$set(
          this.addroomataForm,
          'elewanguang',
          this.addroomataForm.wanguang
        )
        this.$set(
          this.addroomataForm,
          'airwanguang',
          this.addroomataForm.wanguang
        )
        this.$set(
          this.addroomataForm,
          'homewanguang',
          this.addroomataForm.wanguang
        )
        // MC3611	91	MC3612	92 CT1601	93 CT1612	95	MC3622	96	MC3632	98
        if (val.controllerModel == 91 || val.controllerModel == 92) {
          // 门锁
          this.doorlockoption = [
            { value: 43, label: 'EL200CW' },
            { value: 45, label: 'EL150CW' },
            { value: 48, label: 'EL300CW' },
            { value: 49, label: 'EL180CW' }
          ]
          // 水控
          this.wateroption = [
            { value: 32, label: 'F300CW' },
            { value: 50, label: 'F500CW' },
            { value: 51, label: 'F600CW' }
          ]
          this.electricityoption = []
        } else if (val.controllerModel == 96) {
          // 门锁
          this.doorlockoption = [
            { value: 43, label: 'EL200CW' },
            { value: 45, label: 'EL150CW' },
            { value: 48, label: 'EL300CW' },
            { value: 49, label: 'EL180CW' }
          ]
          // 水控
          this.wateroption = [
            { value: 56, label: 'F562CW' },
            { value: 59, label: 'F662CW' }
          ]
          // 电控
          this.electricityoption = []
        } else if (val.controllerModel == 93 || val.controllerModel == 95) {
          // 门锁
          this.doorlockoption = [
            { value: 46, label: 'EL150C-A' },
            { value: 47, label: 'EL150C-B' }
          ]
          this.wateroption = []
          this.electricityoption = []
        } else if (val.controllerModel == 97) {
          // 电控
          this.electricityoption = [{ value: 71, label: 'EC100' }]
          this.wateroption = []
          this.doorlockoption = []
        } else if (val.controllerModel == 98) {
          // 电控
          this.electricityoption = []
          // 水控
          this.wateroption = [
            { value: 56, label: 'F562CW' },
            { value: 59, label: 'F662CW' }
          ]
          // 门锁
          this.doorlockoption = [
            { value: 43, label: 'EL200CW' },
            { value: 45, label: 'EL150CW' },
            { value: 46, label: 'EL150C-A' },
            { value: 47, label: 'EL150C-B' },
            { value: 48, label: 'EL300CW' },
            { value: 49, label: 'EL180CW' }
          ]
        } else {
          // 门锁
          this.doorlockoption = [
            { value: 43, label: 'EL200CW' },
            { value: 45, label: 'EL150CW' },
            { value: 46, label: 'EL150C-A' },
            { value: 47, label: 'EL150C-B' },
            { value: 48, label: 'EL300CW' },
            { value: 49, label: 'EL180CW' }
          ]
          // 水控
          this.wateroption = [
            { value: 32, label: 'F300CW' },
            { value: 50, label: 'F500CW' },
            { value: 51, label: 'F600CW' },
            { value: 56, label: 'F562CW' },
            { value: 59, label: 'F662CW' }
          ]
          // 电控
          this.electricityoption = [{ value: 71, label: 'EC100' }]
        }
        // 空调
        this.airconditioningoption = [{ value: 125, label: 'KongTiao' }]
        // 归宿终端
        this.hometerminaloption = [{ value: 130, label: 'GuiSuZhongDuan' }]
      }
      // 食堂、小卖部
      if (this.roomradio == 1 || this.roomradio == 3) {
        this.addroomataForm.consumptiontype = ''
        // 充值机
        this.recharge = []
        // 圈存机
        this.circling = [];
        // 消费机
        if (val.controllerModel == 91 || val.controllerModel == 92) {
          // 消费
          this.consumption = [
            { value: 53, label: 'S810CW' },
            { value: 55, label: 'S910CW' }
          ]
        } else if (val.controllerModel == 96 || val.controllerModel == 98) {
          // 消费
          this.consumption = [
            { value: 57, label: 'S862CW' },
            { value: 58, label: 'S962CW' },
            { value: 65, label: 'S863CW' },
            { value: 66, label: 'S963CW' }
            // { value: 61, label: "S962CW_CZ" },
          ]
          this.recharge = [
            { value: 61, label: 'S962CW_CZ' },
            { value: 67, label: 'S963CW_CZ' }
          ]
        this.circling = [
            { value: 68, label: 'S963CW-QC' }
        ];

        } else {
          // 消费
          this.consumption = [
            { value: 53, label: 'S810CW' },
            { value: 55, label: 'S910CW' },
            { value: 57, label: 'S862CW' },
            { value: 58, label: 'S962CW' },
            { value: 65, label: 'S863CW' },
            { value: 66, label: 'S963CW' }
            // { value: 61, label: "S962CW_CZ" },
          ]
          this.recharge = [
            { value: 61, label: 'S962CW_CZ'},
            {value: 67, label: 'S963CW_CZ' }
          ]
          this.circling = [
            { value: 68, label: 'S963CW-QC' }
        ];
        }
      }
      // 公共场所
      if (this.roomradio == 4) {
        //无人售货
        this.addroomataForm.unsold = ''
        //直饮水
        this.addroomataForm.drinkingwater = ''
        // 电吹风
        this.addroomataForm.hairdryer = ''
        // 公话
        this.addroomataForm.voip = ''
        this.addroomataForm.sendcards = ''
        if (val.controllerModel == 91 || val.controllerModel == 92) {
          // 直饮水
          this.drinkingwateroption = [
            { value: 32, label: 'F300CW' },
            { value: 50, label: 'F500CW' },
            { value: 51, label: 'F600CW' }
          ]
        } else if (val.controllerModel == 96 || val.controllerModel == 98) {
          // 直饮水
          this.drinkingwateroption = [
            { value: 56, label: 'F562CW' },
            { value: 59, label: 'F662CW' }
          ]
        } else {
          // 直饮水
          this.drinkingwateroption = [
            { value: 32, label: 'F300CW' },
            { value: 50, label: 'F500CW' },
            { value: 51, label: 'F600CW' },
            { value: 56, label: 'F562CW' },
            { value: 59, label: 'F662CW' }
          ]
        }
      }
    },

    //获取楼层
    getfloors(val) {
      this.layers = val
      // this.getcontrollerpithy()
    },
    //选择设备类型
    checketerminalselect() {
      console.log(this.addroomataForm)
      this.addroomataForm.wanguang = ''
      // 初始化
      this.wanguangChange({ controllerModel: -1 })

      console.log(this.wanguangoptionInit1, this.wanguangoptionInit2)
      if (this.roomradio == 0) {
        this.addroomataForm.wanguangoption = JSON.parse(
          JSON.stringify(this.wanguangoptionInit1)
        )
      }
      if (this.roomradio == 1 || this.roomradio == 3) {
        this.addroomataForm.wanguangoption = JSON.parse(
          JSON.stringify(this.wanguangoptionInit2)
        )
      }
      if (this.roomradio == 2) {
        this.terminalselect(21, this.accesscontroloption)
      }
      if (this.roomradio == 4) {
        this.addroomataForm.wanguangoption = JSON.parse(
          JSON.stringify(this.wanguangoptionInit)
        )
        this.terminalselect(26, this.unsoldoption)
        // this.terminalselect(27, this.drinkingwateroption);
        this.terminalselect(28, this.hairdryeroption)
        this.terminalselect(32, this.voipoption)
        this.terminalselect(29, this.sendcardsoption)
      }
    },
    // 获取设备
    terminalselect(type, terminaloption) {
      this.$http({
        url: this.$http.adornUrl('/terminal/terminal-model-select'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            terminalType: type,
            unitGuid: this.unitGuid
          },
          messageType: 0
        })
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          let Arr = data.messageContent
          if (terminaloption.length == 0) {
            for (var i = 0; i < Arr.length; i++) {
              var itemObj = {
                label: Arr[i].modelName,
                value: Arr[i].modelId,
                type: type
              }
              terminaloption.push(itemObj)
            }
            console.log(terminaloption)
          }
        } else {
          this.$message.error(data.errorMessage)
        }
      })
    },
    handleChange(value, direction, movedKeys) {
      console.log(this.value4)
    },
    addroomvisible() {
      this.roomradio = 999
      this.addroomDialogFormVisible = false
      this.addroomataForm.nameListType = ''
      this.$refs['addroomataForm'].resetFields()
    },
    addroomataFormSubmit() {
      if (this.roomradio == '999') {
        this.$message({
          message: '请选择房间类型',
          type: 'warning'
        })
        return
      }
      if (this.addroomataForm.limitNum == '') {
        this.$message({
          message: '请填最大入住人数',
          type: 'warning'
        })
        return
      }
      // if(this.addroomataForm.limitNum!=''){
      //      let limtnumReg =/(^[1-9]\d*$)/
      //      if(!limtnumReg.test(this.addroomataForm.limitNum)){
      //         this.$message({
      //           message: '最大入住人数数据不合法',
      //           type: 'warning'
      //         });
      //      }
      //      return
      // }
      // console.log(typeof this.addroomataForm.roomCode)
      // console.log(typeof this.addroomataForm.roomCodeEnd)
      // return
      if (
        this.addroomataForm.roomCode == '' ||
        this.addroomataForm.roomCodeEnd == ''
      ) {
        this.$message({
          message: '请填写编号',
          type: 'warning'
        })
        return
      }
      if (
        this.addroomataForm.roomCode != '' ||
        this.addroomataForm.roomCodeEnd != ''
      ) {
        let roonumReg = /^99$|^(\d|[1-9]\d)$/
        if (
          !roonumReg.test(this.addroomataForm.roomCode) ||
          !roonumReg.test(this.addroomataForm.roomCodeEnd)
        ) {
          this.$message({
            message: '序号数据不合法',
            type: 'warning'
          })
          return
        } else {
          let num1 = parseInt(this.addroomataForm.roomCode)
          let num2 = parseInt(this.addroomataForm.roomCodeEnd)
          if (num1 > num2) {
            this.$message({
              message: '序号数据不合法',
              type: 'warning'
            })
            return
          }
        }
      }
      // 门锁选择但是没选择格式
      if (
        this.addroomataForm.doorlock !== '' &&
        this.addroomataForm.nameListType == ''
      ) {
        this.$message({
          message: '门锁设备使用名单格式不能为空',
          type: 'warning'
        })
        return
      }
      this.terminalRequests = []
      if (this.roomradio == 0) {
        if (this.addroomataForm.doorlock !== '') {
          console.log(this.addroomataForm.doorwanguang)

          this.terminalRequests.push({
            terminalModel: this.addroomataForm.doorlock,
            nameListType: this.addroomataForm.nameListType,
            addNumber: this.addroomataForm.doorNumber,
            controllerGuid: this.addroomataForm.doorwanguang.value,
            terminalType: 22
          })
        }
        if (this.addroomataForm.watercontroller !== '') {
          this.terminalRequests.push({
            terminalModel: this.addroomataForm.watercontroller,
            addNumber: this.addroomataForm.waterNumber,
            controllerGuid: this.addroomataForm.waterwanguang.value,
            terminalType: 6
          })
        }
        if (this.addroomataForm.electricity !== '') {
          this.terminalRequests.push({
            terminalModel: this.addroomataForm.electricity,
            addNumber: this.addroomataForm.eleNumber,
            controllerGuid: this.addroomataForm.elewanguang.value,
            terminalType: 31
          })
        }
        if (this.addroomataForm.airconditioning !== '') {
          this.terminalRequests.push({
            terminalModel: this.addroomataForm.airconditioning,
            addNumber: this.addroomataForm.airNumber,
            controllerGuid: this.addroomataForm.airwanguang.value,
            terminalType: 24
          })
        }
        if (this.addroomataForm.hometerminal !== '') {
          this.terminalRequests.push({
            terminalModel: this.addroomataForm.hometerminal,
            addNumber: this.addroomataForm.homeNumber,
            controllerGuid: this.addroomataForm.homewanguang.value,
            terminalType: 25
          })
        }
      }
      if (this.roomradio == 1 || this.roomradio == 3) {
        if (this.addroomataForm.consumptiontype !== '') {
          this.terminalRequests.push({
            terminalModel: this.addroomataForm.consumptiontype,
            terminalType: 1
          })
        }
        if (this.addroomataForm.rechargetype !== '') {
          this.terminalRequests.push({
            terminalModel: this.addroomataForm.rechargetype,
            terminalType: 2
          })
        }
        // 圈存机
         if (this.addroomataForm.circlingtype !== '') {
          this.terminalRequests.push({
            terminalModel: this.addroomataForm.circlingtype,
            terminalType: 33
          })
        }
      }
      if (this.roomradio == 2) {
        if (this.addroomataForm.accesscontrol !== '') {
          let portReg = /^((25[0-5]|2[0-4]\d|[01]?\d\d?)($|(?!\.$)\.)){4}$/
          let portReg1 = /^[1-9]$|(^[1-9][0-9]$)|(^[1-9][0-9][0-9]$)|(^[1-9][0-9][0-9][0-9]$)|(^[1-6][0-5][0-5][0-3][0-5]$)/
          console.log(!portReg.test(this.addroomataForm.ip))
          // 是否是新门禁
          if (this.isNewAcce(this.addroomataForm.accesscontrol)) {
            this.addroomataForm.roomCode = parseInt(
              this.addroomataForm.roomCodeEnd
            )
            if (this.addroomataForm.doorFaceIp != '') {
              if (!portReg.test(this.addroomataForm.doorFaceIp)) {
                this.$message.error('人脸机ip格式不正确')
                return
              }
            }

            if (
              this.addroomataForm.doorCode == '' ||
              this.addroomataForm.acceWanguang == ''
            ) {
              this.$message.error('控制器名称、门编号必须填写')
              return
            } else {
              this.terminalRequests.push({
                terminalModel: this.addroomataForm.accesscontrol,
                doorCode: this.addroomataForm.doorCode,
                openType: this.addroomataForm.openType,
                doorFaceIp: this.addroomataForm.doorFaceIp,
                terminalType: 21
              })
            }
            console.log(this.terminalRequests)
          } else {
            if (
              this.addroomataForm.ip === '' ||
              this.addroomataForm.port === ''
            ) {
              this.$message.error('ip、端口必须填写')
              return
            } else {
              if (!portReg.test(this.addroomataForm.ip)) {
                this.$message.error('ip格式不正确')
                return false
              } else if (!portReg1.test(this.addroomataForm.port)) {
                this.$message.error('端口格式不正确')
                return false
              } else {
                this.terminalRequests.push({
                  terminalModel: this.addroomataForm.accesscontrol,
                  ip: this.addroomataForm.ip,
                  port: this.addroomataForm.port,
                  terminalType: 21
                })
              }
            }
          }
        }
      }
      if (this.roomradio == 4) {
        if (this.addroomataForm.unsold !== '') {
          this.terminalRequests.push({
            terminalModel: this.addroomataForm.unsold,
            terminalType: 26
          })
        }
        if (this.addroomataForm.drinkingwater !== '') {
          this.terminalRequests.push({
            terminalModel: this.addroomataForm.drinkingwater,
            // terminalType: 27,
            terminalType: 6
          })
        }
        if (this.addroomataForm.hairdryer !== '') {
          this.terminalRequests.push({
            terminalModel: this.addroomataForm.hairdryer,
            terminalType: 28
          })
        }
        if (this.addroomataForm.voip !== '') {
          this.terminalRequests.push({
            terminalModel: this.addroomataForm.voip,
            terminalType: 32
          })
        }
        if (this.addroomataForm.sendcards !== '') {
          this.terminalRequests.push({
            terminalModel: this.addroomataForm.sendcards,
            terminalType: 29
          })
        }
      }
      this.$refs['addroomataForm'].validate(valid => {
        if (valid) {
          // console.log({
          //   areaGuid: this.areaid,
          //   buildingGuid: this.buildingGuid,
          //   terminalRequests: this.terminalRequests,
          //   roomCode: this.addroomataForm.roomCode,
          //   roomCodeEnd: parseInt(this.addroomataForm.roomCodeEnd),
          //   layers: this.layers,
          //   limitNum: this.addroomataForm.limitNum,
          //   unitGuid: this.unitGuid,
          //   controllerGuid:
          //     this.roomradio == 2
          //       ? this.addroomataForm.acceWanguang
          //       : this.addroomataForm.wanguang.value,
          //   roomType: this.roomradio,
          //   roomName: this.addroomataForm.roomname
          // })
          // return
          this.$http({
            url: this.$http.adornUrl('/area/room/add-room-info'),
            method: 'post',
            data: this.$http.adornData({
              messageContent: {
                areaGuid: this.areaid,
                buildingGuid: this.buildingGuid,
                terminalRequests: this.terminalRequests,
                roomCode: this.addroomataForm.roomCode,
                roomCodeEnd: parseInt(this.addroomataForm.roomCodeEnd),
                layers: this.layers,
                limitNum: this.addroomataForm.limitNum,
                unitGuid: this.unitGuid,
                // 门禁网关
                controllerGuid:
                  this.roomradio == 2
                    ? this.addroomataForm.acceWanguang
                    : this.addroomataForm.wanguang.value,
                roomType: this.roomradio,
                roomName: this.addroomataForm.roomname
              },
              messageType: 0
            })
          }).then(({ data }) => {
            if (data.messageCode == 200) {
              let str = data.errorMessage ? data.errorMessage : '添加成功'
              this.$message({
                type: 'success',
                message: str
              })
              this.$emit(
                'deletroomlist',
                this.layers,
                this.pageSize,
                this.pageNum
              )
              this.roomradio = 999
              this.addroomDialogFormVisible = false
              this.$refs['addroomataForm'].resetFields()
            } else {
              this.$message.error(data.errorMessage)
            }
          })
        }
      })
    },
    addroominit(areabuldingname, buttonindex) {
      this.addroomataForm.areabuldingname = areabuldingname
      this.addroomataForm.layers = buttonindex + 1
      this.addroomDialogFormVisible = true
      //  this.addroomataForm.wanguangoption=[]
      this.wanguangoptionto()
      //  console.log(this.gatewayvalue)
    },
    roomcloseDialog(done) {
      this.roomradio = 999
      this.$refs['addroomataForm'].resetFields()
      done()
    },
    bundlegatewayroomvisible() {
      this.bundlegatewayVisible = false
      this.gatewayvalue = []
    },
    roomgatewacloseDialog() {
      this.bundlegatewayVisible = false
      this.gatewayvalue = []
    },
    bundlegatewayroomataFormSubmit() {
      this.$http({
        url: this.$http.adornUrl('/area/room/bind-building-layer-controller'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            buildingGuid: this.buildingGuid,
            controllerGuidList: this.gatewayvalue,
            layer: this.layers
          },
          messageType: 0
        })
      }).then(({ data }) => {
        console.log(data)
        if (data.messageCode == 200) {
          this.$message({
            type: 'success',
            message: '绑定成功!'
          })
          this.gatewayvalue = []
          this.bundlegatewayVisible = false
          //  this.addroomataForm.wanguangoption=[]
        } else {
          this.$message.error(data.errorMessage)
        }
      })
    },
    bundlegatewayinit() {
      this.$http({
        url: this.$http.adornUrl('/area/room/building-details'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            buildingGuid: this.buildingGuid,
            unitGuid: this.unitGuid
          },
          messageType: 0
        })
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          let controllerList = data.messageContent.controllerList || []
          let newARR = []
          for (var i = 0; i < controllerList.length; i++) {
            newARR.push({
              key: controllerList[i].controllerGuid,
              label: controllerList[i].controllerName
            })
          }
          this.controllerListdata = newARR
          this.getcontrollerpithy()
        } else {
          this.$message.error(data.errorMessage)
        }
      })
    },
    //获取楼层具体详情信息
    gebuilddetails(buildingid, changeschoolid, areaid) {
      this.areaid = areaid
      this.buildingGuid = buildingid
    },
    //删除房间
    deletroominit(item) {
      this.$confirm('此操作将永久删除该房间, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.deletroom(item)
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    deletroom(item) {
      console.log(this.changeschoolid)
      this.$http({
        url: this.$http.adornUrl('/area/room/delete-room-info'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            roomGuid: item.roomGuid,
            roomType: item.roomType,
            unitGuid: this.changeschoolid
          },
          messageType: 0
        })
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          this.$message({
            type: 'success',
            message: '删除成功!',
            duration: 500,
            onClose: () => {
              this.$emit(
                'deletroomlist',
                this.layers,
                this.pageSize,
                this.pageNum
              )
            }
          })
        } else {
          this.$message.error(data.errorMessage)
        }
      })
    },
    //获得该楼层控制器信息
    getcontrollerpithy() {
      this.$http({
        url: this.$http.adornUrl('/api/v1/device/controller-pithy'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            buildingGuid: this.buildingGuid,
            layer: this.layers
          },
          messageType: 0
        })
      }).then(({ data }) => {
        console.log(data)
        if (data.messageCode == 200) {
          let arr = data.messageContent
          for (var i = 0; i < arr.length; i++) {
            this.gatewayvalue.push(arr[i].controllerGuid)
          }
          this.bundlegatewayVisible = true
        } else {
          this.$message.error(data.errorMessage)
        }
      })
    },

    // 根据类型去分类,网关显示
    getInfo(arr) {
      console.log(arr)
      // 房间的
      // 网关
      this.wanguangoptionInit = []
      this.wanguangoptionInit1 = []
      this.wanguangoptionInit2 = []
      arr.map(item => {
        // 房间
        if (
          item.controllerModel == 91 ||
          item.controllerModel == 92 ||
          item.controllerModel == 93 ||
          item.controllerModel == 95 ||
          item.controllerModel == 96 ||
          item.controllerModel == 97 ||
          item.controllerModel == 98
        ) {
          this.wanguangoptionInit1.push({
            label: item.controllerName,
            value: item.controllerGuid,
            controllerModel: item.controllerModel
          })
        }
        if (
          item.controllerModel == 91 ||
          item.controllerModel == 92 ||
          item.controllerModel == 96 ||
          item.controllerModel == 98
        ) {
          // 食堂、小卖铺
          this.wanguangoptionInit2.push({
            label: item.controllerName,
            value: item.controllerGuid,
            controllerModel: item.controllerModel
          })
          // // 公共场所
          this.wanguangoptionInit.push({
            label: item.controllerName,
            value: item.controllerGuid,
            controllerModel: item.controllerModel
          })
        }
      })
    },
    wanguangoptionto() {
      this.addroomataForm.wanguangoption = []
      // this.addroomataForm.wanguangoptionInit = [];
      this.$http({
        url: this.$http.adornUrl('/api/v1/device/controller-pithy'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            buildingGuid: this.buildingGuid,
            layer: this.layers
          },
          messageType: 0
        })
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          console.log(data)
          let arr = data.messageContent
          this.getInfo(arr)
          for (var i = 0; i < arr.length; i++) {
            let newobj = {
              label: arr[i].controllerName,
              value: arr[i].controllerGuid,
              controllerModel: arr[i].controllerModel
            }
            this.addroomataForm.wanguangoption.push(newobj)
            // this.addroomataForm.wanguangoptionInit.push(newobj);
          }
        } else {
          this.$message.error(data.errorMessage)
        }
      })
    },
    getpagesize(val) {
      this.pageSize = val
    },
    getpagenume(val) {
      this.pageNum = val
    }
  }
}
</script>

<style lang="scss" scoped>
.are_buil_romm {
  /deep/.el-dialog--center .el-dialog__body {
    padding: 5px 30px;
    padding-right: 5px;
  }
  //滚动条的宽度
  ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
  }

  //滚动条的滑块
  ::-webkit-scrollbar-thumb {
    background-color: #a1a3a9;
    border-radius: 3px;
  }
  .el-form-item {
    margin-bottom: 5px;
  }
  .xuhaoxain {
    display: flex;
    justify-content: center;
  }
  #addroom_css {
    .el-radio + .el-radio {
      margin-left: 10px;
    }
    .el-radio {
      margin-right: 0px;
    }
  }
}
</style>